import { setshow } from '../../../utils/auth'

export default {
  addView({ dispatch }, view) {
    dispatch('addVisitedView', view)
    dispatch('addCachedView', view)
  },
  addVisitedView({ commit }, view) {
    commit('ADD_VISITED_VIEW', view)
  },
  addCachedView({ commit }, view) {
    commit('ADD_CACHED_VIEW', view)
  },
  delView({ dispatch, state }, view) {
    return new Promise(resolve => {
      dispatch('delVisitedView', view)
      dispatch('delCachedView', view)
      resolve({
        visitedViews: [...state.visitedViews],
        cachedViews: [...state.cachedViews]
      })
    })
  },
  delVisitedView({ commit, state }, view) {
    return new Promise(resolve => {
      commit('DEL_VISITED_VIEW', view)
      resolve([...state.visitedViews])
    })
  },
  delCachedView({ commit, state }, view) {
    return new Promise(resolve => {
      commit('DEL_CACHED_VIEW', view)
      resolve([...state.cachedViews])
    })
  },
  setReceiveNo({ commit }, value) {
    commit('SET_RECEIVENO', value)
    setApproReceiveNo(value)
  },
  setStatus({ commit }, value) {
    commit('SET_STATUS', value)
  },
  showImageDialog({ commit }) {
    commit('UPDATE_IMAGE', true)
  },
  offImageDialog({ commit }) {
    commit('UPDATE_IMAGE', false)
  },
  showChangeAddrDialog({ commit }) {
    commit('UPDATE_ADDR', true)
  },
  offChangeAddrDialog({ commit }) {
    commit('UPDATE_ADDR', false)
  },
  setshow({ commit }, value) {
    commit('SET_SHOW', value)
    setshow(value)
  }
  
}
